<%--
  Created by IntelliJ IDEA.
  User: KaiFaBu010
  Date: 2017-12-22
  Time: 18:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <jsp:include page="/WEB-INF/jsp/head.jsp">
        <jsp:param value="游戏账号分数结算" name="pageTitle"/>
    </jsp:include>
    <script src="/js/common.js"></script>
</head>

<style>
    a:link {color:green;}
    a:hover {color:#FF00FF;}
</style>
<body class="easyui-layout">


<div class="easyui-panel" data-options="fit:true" style="width:100%;height:100%;padding:10px;">
    <table id="gameAccByDelTb" class="easyui-datagrid" style="width:100%;height:100%">

    </table>

</div>


<script>



    var data = [];
    for (var i = 1; i < 31; ++i) {
        data.push({
            "id":i,
            "text":"text" + i
        })
    }


    var isEditable={};

    $('#gameAccByDelTb').datagrid({
        iconCls: 'icon-search',
        title: '游戏账号分数结算',
        url: '/goHome/getGHAll',
        queryParams: {ssbegin: "", ssend: ""},
        method: 'get',
        singleSelect: "false",
        checkOnSelect: 'false',
        rownumbers: true,
        pagination: true,
        toolbar: '#tb',
        pageSize: 20,
        pageList: [10, 20, 30],
        columns: [[
            {field: 'ck', checkbox: true}
            , {field: 'adid', align: 'center', width: '100', title: '游戏账号交易记录ID', hidden: "true"}
            , {field: 'did', width: '100', align: 'left', title: '交易ID',hidden: "true"}
            , {field: 'gid', width: '100', align: 'left', title: '游戏ID',hidden: "true"}
            , {field: 'gname', width: '100', align: 'left', title: '游戏名字'}
            , {field: 'aid', width: '100', align: 'left', title: '游戏账号id',hidden: "true"}
            , {field: 'accountnum', width: '100', align: 'left', title: '游戏账号名字'}
            , {field: 'initialscore', align: 'left', width: '200', title: '账号上现有分值', formatter: formatNumber}
            , {field: 'sendscore', align: 'left', width: '100', title: '随账出分', formatter: formatNumber}
            , {field: 'getscore', align: 'left', width: '100', title: '随账得分', formatter: formatNumber}
            , {field: 'canotscore', align: 'left', width: '100', title: '未敲分数',editor:{type:'numberbox',options:{precision:0}}}
            , {field: 'finalscore', align: 'left', width: '100', title: '录入的账号最后分',editor:{type:'numberbox',options:{precision:0}}}
            , {field: 'shift', align: 'left', width: '100', title: '班次',formatter: StateCodetoString}
            , {field: 'handlerid', width: '100', align: 'left', title: '操作者ID',hidden: "true"}
            , {field: 'handlers', align: 'left', width: '100', title: '操作者'}
            , {field: 'remark', align: 'left', width: '100', title: '其他说明'}
            , {field: 'modifytime', align: 'center', width: '200', title: '记录时间'}
        ]],toolbar: [{
                text: '编辑',
                iconCls: 'icon-edit',
                handler: function(){
                    if(isEditable['index'] != undefined){
                        $.messager.alert('提示','您正在编辑其他行，请先保存或取消编辑');
                        return;
                    }
                    var dt = $('#gameAccByDelTb').datagrid("getSelected");
                    var index = $('#gameAccByDelTb').datagrid("getRowIndex",dt);
                    if(index == null || index == -1){
                        $.messager.alert('提示','请先选择一行进行编辑');
                        return;
                    }
                    isEditable['index'] = index;
                    $('#gameAccByDelTb').datagrid("beginEdit",index);
                }
            },'-',{
                text:'取消编辑',
                iconCls:'icon-cancel',
                handler:function(){
                    if(isEditable['index'] != undefined){
                        $('#gameAccByDelTb').datagrid("cancelEdit",isEditable['index']);
                        isEditable['index'] = undefined;
                    }
                }
            },'-',{
                text:'保存',
                iconCls:'icon-save',
                handler:function(){
                    if(isEditable['index'] == undefined){
                        $.messager.alert('提示','请先选择一行进行编辑完后,再进行保存');
                        return;
                    }
                    $('#gameAccByDelTb').datagrid("endEdit",isEditable['index']);
                    isEditable['index'] = undefined;
                }
            },'-',{
            text:'刷新',
            iconCls:'fa fa-refresh',
            handler:function(){
                location.reload();
            }},'-',{
            text:'确认下班',
            iconCls:'icon-save',
            handler:function(){

                    var rows = $('#gameAccByDelTb').datagrid('getRows');
                    var entities = [];
                    for(var i = 0;i < rows.length;i++)
                    {
                        entities.push( JSON.stringify(rows[i])+"|");
                    }
                    $.ajax({
                        url: "/goHome/saveGoHome",
                        type: "POST",
                        async: true,
                        dataType: 'json',
                        data: {"entities": entities.toString()},
                        success: function (data) {
                            $.messager.alert('提示信息', data["msg"], 'warning', function () {
                                $('#gameAccByDelTb').datagrid('reload');
                            });

                        }
                    });

            }}
            ],
        onLoadSuccess: function (data) {
            if (data.total == 0) {
                $.messager.alert('提示信息', '没有相关记录！', 'warning');
            }
//            var index = 0;
//            var data2 = $('#gameAccByDelTb').datagrid('selectRow',index);
//            if(data2){
//                isEditable['index'] = index;
//                $('#gameAccByDelTb').datagrid("beginEdit",index);
//            }
        }
    });




</script>
</body>
</html>
